package com.secondkill.service;

import com.secondkill.dao.GoodsMapper;
import com.secondkill.dao.MiaoshaGoodsMapper;
import com.secondkill.entity.MiaoshaGoods;
import com.secondkill.entity.MiaoshaUser;
import com.secondkill.vo.GoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by IBM on 2018/7/9.
 */
@Service
public class MiaoshaGoodsService {

    @Autowired
    GoodsMapper goodsMapper;

    public List<GoodsVo> listGoodsVo() {
        return goodsMapper.listGoodsVo();
    }

    public GoodsVo getGoodsVoByGoodsId(long goodsId) {
        return goodsMapper.getGoodsVoByGoodsId(goodsId);
    }

    public void reduceStock(GoodsVo goods) {
        MiaoshaGoods miaoshaGoods = new MiaoshaGoods();
        miaoshaGoods.setGoodsId(goods.getId());
        goodsMapper.reduceStock(miaoshaGoods);
    }
}
